﻿// Apache-2.0 License
// Copyright (c) 2021-2022 zuohuaijun


using Nest;

namespace Corpus.Core;
/// <summary>
/// ES日志写入器
/// </summary>
public class ElasticSearchLoggingWriter : IDatabaseLoggingWriter
{
    private readonly ElasticClient _esClient;

    public ElasticSearchLoggingWriter(ElasticClient esClient)
    {
        _esClient = esClient;
    }

    public void Write(LogMessage logMsg, bool flush)
    {
        _esClient.IndexDocument(logMsg.Context.Get("loggingMonitor"));
    }
}